package com.tuhu.server.web.controller;

import com.tuhu.server.db.bean.ActivateRecordBean;
import com.tuhu.server.web.bean.ActivateResultBean;
import com.tuhu.server.web.bean.InsertActiveCodeBean;
import com.tuhu.server.web.bean.MockResultBean;
import com.tuhu.server.web.controller.service.AccountService;
import com.tuhu.server.web.resp.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1")
public class AccountController {

    @Autowired
    AccountService accountService;

    ///////////////////////   登录   ////////////////////////////
    //////////////////////////////////////////////////////
    @GetMapping("/activate")
    public ResponseEntity<ResultBean<ActivateResultBean>> activate(
            @RequestParam("activeCode") String activeCode,
            @RequestParam("deviceId") String deviceId,
            @RequestParam("brand") String brand,
            @RequestParam("model") String model) {
        return accountService.activate(activeCode, deviceId, brand, model);
    }
    @GetMapping("/mock")
    public ResponseEntity<ResultBean<MockResultBean>> mock(
            @RequestParam("activeCode") String activeCode,
            @RequestParam("deviceId") String deviceId,
            @RequestParam("brand") String brand,
            @RequestParam("model") String model,
            @RequestParam("lat") double lat,
            @RequestParam("lng") double lng) {
        return accountService.mock(activeCode, deviceId, brand, model, lat, lng);
    }

    @GetMapping("/insert_active_code")
    public ResponseEntity<ResultBean<InsertActiveCodeBean>> insert_active_code(
            @RequestParam("activeCode") String activeCode,
            @RequestParam("activeCodeType") int activeCodeType,
            @RequestParam("password") String password) {
        return accountService.insert_active_code(activeCode, activeCodeType, password);
    }

    @GetMapping("/unbind")
    public ResponseEntity<ResultBean<Void>> unbind(
            @RequestParam("activeCode") String activeCode,
            @RequestParam("password") String password) {
        return accountService.unbind(activeCode, password);
    }

    @GetMapping("/query")
    public ResponseEntity<ResultBean<ActivateRecordBean>> query(
            @RequestParam("activeCode") String activeCode,
            @RequestParam("password") String password) {
        return accountService.query(activeCode, password);
    }


}
